package com.haoan.index.service.impl;


import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.haoan.index.common.enums.ValiFlag;

import com.haoan.index.mapper.LcBusinessMapper;
import com.haoan.index.domain.LcBusiness;
import com.haoan.index.service.LcBusinessService;

/**
 * 业务Service业务层处理
 * 
 * @author autoGen
 * @date 2025-03-21
 */
@Service
public class LcBusinessServiceImpl extends ServiceImpl<LcBusinessMapper,LcBusiness> implements LcBusinessService
{
    /**
     * 查询业务
     * 
     * @param id 业务主键
     * @return 业务
     */
    @Override
    public LcBusiness selectLcBusinessById(Long id)
    {
        return baseMapper.selectById(id);
    }

    /**
     * 查询业务列表
     * 
     * @param lcBusiness 业务
     * @return 业务
     */
    @Override
    public List<LcBusiness> selectLcBusinessList(LcBusiness lcBusiness)
    {
        LambdaQueryWrapper<LcBusiness> queryWrapper = new LambdaQueryWrapper<>();
        //todo 添加查询条件
        queryWrapper.eq(lcBusiness.getId() != null, LcBusiness::getId, lcBusiness.getId());
        queryWrapper.like(lcBusiness.getName() != null, LcBusiness::getName, lcBusiness.getName());
        queryWrapper.like(lcBusiness.getIntroduce() != null, LcBusiness::getIntroduce, lcBusiness.getIntroduce());
        queryWrapper.eq(lcBusiness.getImage() != null, LcBusiness::getImage, lcBusiness.getImage());
        queryWrapper.eq(lcBusiness.getTime() != null, LcBusiness::getTime, lcBusiness.getTime());
        queryWrapper.orderByDesc(LcBusiness::getTime);
        return baseMapper.selectList(queryWrapper);
    }

    /**
     * 新增业务
     * 
     * @param lcBusiness 业务
     * @return 结果
     */
    @Transactional
    @Override
    public int insertLcBusiness(LcBusiness lcBusiness)
    {
        return baseMapper.insert(lcBusiness);
    }

    /**
     * 修改业务
     * 
     * @param lcBusiness 业务
     * @return 结果
     */
    @Transactional
    @Override
    public int updateLcBusiness(LcBusiness lcBusiness)
    {
        return baseMapper.updateById(lcBusiness);
    }

    /**
     * 批量删除业务
     * 
     * @param ids 需要删除的业务主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteLcBusinessByIds(Long [] ids)
    {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除业务信息
     * 
     * @param id 业务主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteById(Long id)
    {
        return baseMapper.deleteById(id);
    }
}
